package sqlanalysisgui.editor;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import sqlanalysisgui.view.model.ProjectInfo;

public class DashboardTableInput implements IEditorInput {
	/*
	 * hashCode(), equals() 를 구현하지 않으면 똑같은 창이 새로 열린다.
	 */
	private final ProjectInfo projectInfo;

	public DashboardTableInput(ProjectInfo projectInfo) {
		this.projectInfo = projectInfo;
	}

	public ProjectInfo getProjectInfo() {
		return projectInfo;
	}

	@Override
	public String getToolTipText() {
		return "Displays DashBoard";
	}

	@Override
	public Object getAdapter(Class adapter) {
		// CHO Auto-generated method stub
		return null;
	}

	@Override
	public boolean exists() {
		// CHO Auto-generated method stub
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		// CHO Auto-generated method stub
		return null;
	}

	@Override
	public String getName() {
		// CHO Auto-generated method stub
		return this.projectInfo.getProjectName();
	}

	@Override
	public IPersistableElement getPersistable() {
		// CHO Auto-generated method stub
		return null;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((projectInfo == null) ? 0 : projectInfo.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DashboardTableInput other = (DashboardTableInput) obj;
		if (projectInfo == null) {
			if (other.projectInfo != null)
				return false;
		} else if (!projectInfo.equals(other.projectInfo))
			return false;
		return true;
	}

}
